event_time = gtk_get_current_event_time ();
}
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
- button, event_time);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), event);
}
gtk_widget_set_default_direction (GTK_TEXT_DIR_LTR);
}
-typedef struct
-{
- int x;
- int y;
-} MenuPositionData;
-
-static void
-position_function (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
-{
- /* Do not do this in your own code */
-
- MenuPositionData *position_data = user_data;
-
- if (x)
- *x = position_data->x;
-
- if (y)
- *y = position_data->y;
-
- if (push_in)
- *push_in = FALSE;
-}
-
static gboolean
popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button_number)
{
- MenuPositionData position_data;
-
GtkMenu *menu = GTK_MENU (gtk_menu_new ());
int i;
item = gtk_menu_item_new_with_mnemonic (label);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
}
- gtk_widget_show (GTK_WIDGET (menu));
if (button_number != -1)
{
- position_data.x = x;
- position_data.y = y;
-
- gtk_menu_popup (menu, NULL, NULL, position_function,
- &position_data, button_number, gtk_get_current_event_time());
+ gtk_menu_popup_at_pointer (menu, NULL);
}
else
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
+ {
+ GtkWindow *window;
+ GtkWidget *widget;
+
+ window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (toolbar)));
+ widget = gtk_window_get_focus (window);
+ if (!widget)
+ widget = GTK_WIDGET (toolbar);
+
+ gtk_menu_popup_at_widget (menu,
+ widget,
+ GDK_GRAVITY_SOUTH_EAST,
+ GDK_GRAVITY_NORTH_WEST,
+ NULL);
+ }
return TRUE;
}